package com.qingsong.controller.test;

import com.qingsong.exception.ServiceException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class ExceptionController {  
      
    @GetMapping("/test/exception/{num}")
    public Object exception(@PathVariable Integer num) {
        if (num == 0) {  
            throw new RuntimeException("未知异常");  
        }  
        if (num == 1) {  
            throw new ServiceException("除数不能为0");
        }  
        return Map.of("name", "zhaosi");
    }  
}